package com.paddyi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.paddyi.commons.http.HttpResult;
import com.paddyi.model.Account;
import com.paddyi.service.IAccountService;

/**
 *  (Account)
 * @author paddy
 * @since  2019-08-09 12:00:53
 */
@RestController
@RequestMapping("account")
public class AccountController {

	@Autowired
	private IAccountService accountService;

	/**
	 * 保存
	 *
	 * @param record
	 * @return
	 */
	@PostMapping(value = "/add")
	public HttpResult add(@RequestBody Account record) {
		return HttpResult.ok(accountService.save(record));
	}


	/**
	 * 支付
	 *
	 * @param record
	 * @return
	 */
	@PostMapping(value = "/pay")
	public HttpResult pay(@RequestBody Account record) {
		return HttpResult.ok(accountService.pay(record));
	}

	/**
	 * 查询
	 *
	 * @param userId
	 * @return
	 */
	@PostMapping(value = "/getAccount")
	public HttpResult getAccount(@RequestBody Long userId) {
		return HttpResult.ok(accountService.findAccountByUserId(userId));
	}
}
